<?php


namespace app\api\controller\System;


use app\api\controller\BaseController;
use app\api\model\System\SysSettingModel;
use app\Request;
use app\Utils\Util;

class System extends BaseController
{

    /**
     * @api {get} /get_contact_way 联系我们
     * @apiGroup 系统
     * @apiSuccess {int} code 状态码 0：正常 -1：错误
     * @apiSuccess {json} data 数据源
     * @apiSuccess {string} msg 描述
     * @apiVersion 1.0.0
     */
    public function getContactWay(Request $request)
    {
        $setting = SysSettingModel::getSysSettingWhere([['id','=',1]]);
        if(!empty($setting)){
            $sys_extend = json_decode($setting['sys_extend'],true);
            $contact_way = $sys_extend['contact_way'];
        }else{
            $contact_way = "";
        }
        return Util::returnJson(self::CODE_SUCCESS,$contact_way);
    }

    /**
     * @api {get} /get_about_us 关于我们
     * @apiGroup 系统
     * @apiSuccess {int} code 状态码 0：正常 -1：错误
     * @apiSuccess {json} data 数据源
     * @apiSuccess {string} msg 描述
     * @apiVersion 1.0.0
     */
    public function getAboutUs(Request $request)
    {
        $setting = SysSettingModel::getSysSettingWhere([['id','=',1]]);
        if(!empty($setting)){
            $sys_extend = json_decode($setting['sys_extend'],true);
            $about_us = htmlspecialchars_decode($sys_extend['about_us']);
        }else{
            $about_us = "";
        }
        return Util::returnJson(self::CODE_SUCCESS,$about_us);
    }


    /**
     * @api {get} /get_group_info 拼团规则
     * @apiGroup 系统
     * @apiSuccess {int} code 状态码 0：正常 -1：错误
     * @apiSuccess {json} data 数据源
     * @apiSuccess {string} msg 描述
     * @apiVersion 1.0.0
     */
    public function getGroupInfo(Request $request)
    {
        $setting = SysSettingModel::getSysSettingWhere([['id','=',1]]);
        if(!empty($setting)){
            $info = htmlspecialchars_decode($setting['group_info']);
        }else{
            $info = "";
        }
        return Util::returnJson(self::CODE_SUCCESS,$info);
    }

}